import { Vue, Component } from 'vue-property-decorator';
import CommonMixin from 'src/mixin/common';
@Component
export default class CommentMixin extends CommonMixin {
  // data

  showCommentPen(hostType: string, id: number, quote: Comment) {
    this.$store.commit('comment/setCommentPenPosition', {
      id: id,
      rootType: hostType,
      quote: quote
    });
  }

  hideCommentPen() {
    this.$store.commit('comment/setCommentPenPosition', {
      id: 0,
      rootType: 'article',
      quote: null
    });
  }
  get penVisible(): Function {
    return (rootType: string, id: number): boolean => {
      let temp = this.$store.state.comment.commentPenPosition;
      return temp.rootType == rootType && temp.id == id;
    };
  }

  get commentPenPosition(): any {
    return this.$store.state.comment.commentPenPosition;
  }

  public readonly submitHandler: any = {
    article: () => {},
    comment: () => {},
    reply: () => {}
  };

  //创建评论
  public submit(): void {
    let id = this.commentPenPosition.id;
    let rootType = this.commentPenPosition.rootType;
    this.submitHandler[rootType]();
  }
  get userProfile() {
    return this.$store.getters['login/userProfile'];
  }
}
